﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevComponents.DotNetBar;
using System.Data.SqlClient;
using ECONTACT.Controller;

namespace ECONTACT
{
    public partial class frmHanhKiem : Form
    {
        HanhKiemCtrl m_HanhKiemCtrl = new HanhKiemCtrl();

        public frmHanhKiem()
        {
            InitializeComponent();
        }

        private void frmHanhKiem_Load(object sender, EventArgs e)
        {
            m_HanhKiemCtrl.HienThi(dGVHanhKiem, txtMaHK, txtTenHanhKiem);
        }

        private void btnThem_Click(object sender, EventArgs e)
        {
            m_HanhKiemCtrl.LuuHanhKiem(txtTenHanhKiem.Text);
            m_HanhKiemCtrl.HienThi(dGVHanhKiem, txtMaHK, txtTenHanhKiem);
        }

        private void btnCapNhat_Click(object sender, EventArgs e)
        {
            m_HanhKiemCtrl.UpdateHanhKiem(txtMaHK.Text, txtTenHanhKiem.Text);
            m_HanhKiemCtrl.HienThi(dGVHanhKiem, txtMaHK, txtTenHanhKiem);
        }

        private void btnXoa_Click(object sender, EventArgs e)
        {
            if (dGVHanhKiem.RowCount == 0)
            {
                MessageBox.Show("Bạn chưa chọn dòng nào làm sao xóa!", "Thông báo");
            }
            else if (MessageBoxEx.Show("Bạn có chắc là xóa thiệt hok ?", "DELETE", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                m_HanhKiemCtrl.DeleteHanhKiem(txtMaHK.Text);
                m_HanhKiemCtrl.HienThi(dGVHanhKiem, txtMaHK, txtTenHanhKiem);
            }
            
        }
    }
}
